package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;

import java.util.List;

@Mapper
public interface OrdersMapper {

  @Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0)")
  @Options(useGeneratedKeys = true,keyProperty = "orderId",keyColumn = "orderId")
  public int saveOrders(Orders orders);

  /**
   * 根据id获取到订单
   * @param orderId
   * @return
   */
  public Orders getOrdersById(Integer orderId);

  /**
   * 根据用户的id查询订单列表
   * @param userId
   * @return
   */
  public List<Orders> listOrdersByUserId(String userId);
}
